﻿using System.Text.RegularExpressions;

namespace Common
{
    /// <summary>
    /// 用户Email对应的网站
    /// </summary>
    public class MailRefer
    {
        public static string GetSite(string email)
        {
            string returnValue = "";
            //var i = email.IndexOf("@");
            //var j = email.IndexOf(".");
            //var s = email.Substring(i + 1, email.Length - j - 1);
            var re = new Regex("@\\w+\\.", RegexOptions.IgnoreCase);

            Match match = re.Match(email);

            switch (match.Value)
            {
                case "@gmail.":
                    returnValue = "http://gmail.com";
                    break;
                case "@163.":
                    returnValue = "http://mail.163.com/";
                    break;
                case "@126.":
                    returnValue = "http://mail.126.com/";
                    break;
                case "@qq.":
                    returnValue = "https://mail.qq.com/";
                    break;
                case "@yahoo.":
                    returnValue = "https://mail.yahoo.com/";
                    break;
                case "@sina.":
                    returnValue = "http://mail.sina.com.cn/";
                    break;
                case "@sohu.":
                    returnValue = "http://mail.sohu.com/";
                    break;
                case "@tom.":
                    returnValue = "http://mail.tom.com/";
                    break;
                case "@sogou.":
                    returnValue = "http://mail.sogou.com/";
                    break;
                case "@139.":
                    returnValue = "http://mail.10086.cn/";
                    break;
                case "@189.":
                    returnValue = "http://mail.189.cn/";
                    break;
                case "@eyou.":
                    returnValue = "http://www.eyou.com/";
                    break;
                case "@21cn.":
                    returnValue = "http://mail.21cn.com/";
                    break;
                case "@188.":
                    returnValue = "http://www.188.com/";
                    break;
                case "@yeah.":
                    returnValue = "http://www.yeah.net/";
                    break;
                case "@foxmail.":
                    returnValue = "http://foxmail.com/";
                    break;
                case "@263.":
                    returnValue = "http://www.263.net/";
                    break;
            }

            return returnValue;
        }
    }
}